﻿using MS.InformationManagement.Presenter.Support;
using MS.InformationManagement.BLL.RecordCenter;
namespace MS.InformationManagement.Presenter.ListUploaders
{
    public class ListUploaderPresenter : BasePresenter<IListUploaderView>
    {
        public ListUploaderPresenter(IListUploaderView view) : base(view) { }

        public void UploadeFile()
        {            
            char[] separator = { ';' };
            string errorMessage = string.Empty;
            switch (View.Operation)
            {
                case InformationManagement.Support.Enums.ListUploadOperation.Backdrop:
                    errorMessage = ListLoaderBLL.LoadFileIntoBackdropList(View.FileStream, separator);
                    break;
                case InformationManagement.Support.Enums.ListUploadOperation.Sections:
                    errorMessage = ListLoaderBLL.LoadFileIntoSectionList(View.FileStream, separator);
                    break;
                case InformationManagement.Support.Enums.ListUploadOperation.Series:
                    errorMessage = ListLoaderBLL.LoadFileIntoSeriesList(View.FileStream, separator);
                    break;
                case InformationManagement.Support.Enums.ListUploadOperation.Subseries:
                    errorMessage = ListLoaderBLL.LoadFileIntoSubSeriesList(View.FileStream, separator);
                    break;
                case InformationManagement.Support.Enums.ListUploadOperation.Entities:
                    errorMessage = ListLoaderBLL.LoadEntitiesFileIntoContactList(View.FileStream, separator);
                    break;
                case InformationManagement.Support.Enums.ListUploadOperation.People:
                    errorMessage = ListLoaderBLL.LoadPeopleFileIntoContactList(View.FileStream, separator);
                    break;
                default:
                    throw new System.ArgumentException("Operación inválida");
                    break;
            }
            if (!string.IsNullOrEmpty(errorMessage)) { View.ShowSuccess(errorMessage); } else { View.ShowSuccess(); }
        }
    }
}
